$(function () {

    // Cookie validation
    /*if (jQuery.type($.cookie('skin_color')) != 'undefined') {

        $('aside').removeClass('skin-1');
        $('aside').removeClass('skin-2');
        $('aside').removeClass('skin-3');
        $('aside').removeClass('skin-4');
        $('aside').removeClass('skin-5');
        $('aside').removeClass('skin-6');
        $('#top-nav').removeClass('skin-1');
        $('#top-nav').removeClass('skin-2');
        $('#top-nav').removeClass('skin-3');
        $('#top-nav').removeClass('skin-4');
        $('#top-nav').removeClass('skin-5');
        $('#top-nav').removeClass('skin-6');

        $('aside').addClass($.cookie('skin_color'));
        $('#top-nav').addClass($.cookie('skin_color'));
    }*/

    //Skin color
    $('.theme-color').click(function () {
        //Cookies for storing theme color
        $.cookie('skin_color', $(this).attr('id'));

        $('aside').removeClass('skin-1');
        $('aside').removeClass('skin-2');
        $('aside').removeClass('skin-3');
        $('aside').removeClass('skin-4');
        $('aside').removeClass('skin-5');
        $('aside').removeClass('skin-6');
        $('#top-nav').removeClass('skin-1');
        $('#top-nav').removeClass('skin-2');
        $('#top-nav').removeClass('skin-3');
        $('#top-nav').removeClass('skin-4');
        $('#top-nav').removeClass('skin-5');
        $('#top-nav').removeClass('skin-6');

        $('aside').addClass($(this).attr('id'));
        $('#top-nav').addClass($(this).attr('id'));
    });

    // Delete values stored in cookies 
    // uncomment code to activate
    //	$.removeCookie('skin_color');
    //

    //
    $('.login-link').click(function (e) {
        e.preventDefault();
        href = $(this).attr('href');

        $('.login-wrapper').addClass('fadeOutUp');

        setTimeout(function () {
            window.location = href;
        }, 900);

        return false;
    });

    //Logout Confirmation
    /*$('#logoutConfirm').popup({
        pagecontainer: '.container',
        transition: 'all 0.3s'
    });
     */

    //theme setting
    /*$("#theme-setting-icon").click(function () {
        if ($('#theme-setting').hasClass('open')) {
            $('#theme-setting').removeClass('open');
            $('#theme-setting-icon').removeClass('open');
        } else {
            $('#theme-setting').addClass('open');
            $('#theme-setting-icon').addClass('open');
        }

        return false;
    });*/
    // Popover
    //$("[data-toggle=popover]").popover();

    // Tooltip
    //$("[data-toggle=tooltip]").tooltip();

});

$(document).ready(function () {
    // Fade out the overlay div
    $('#overlay').fadeOut(800);

    $('body').removeAttr('class');

    //Enable animation
    $('#wrapper').removeClass('preload');

    //Collapsible Active Menu
    if (!$('#wrapper').hasClass('sidebar-mini')) {
        $('aside').find('.active.openable').children('.submenu').slideDown();
    }
});

/*$(window).scroll(function () {

    var position = $(window).scrollTop();

    //Display a scroll to top button
    if (position >= 200) {
        $('#scroll-to-top').attr('style', 'bottom:8px;');
    } else {
        $('#scroll-to-top').removeAttr('style');
    }
});*/
(function(){
    var setMainContainer = function(){
        var height = $(window).height();
        $('#main-container').css({'height': (height - 84)+'px'});
        $('aside').css({'height': (height - 45)+'px'});
    };
    $(window).resize(function(){
        setMainContainer();
    });
    setMainContainer();
})();